package com.special.threademo.requests151demo;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.collections4.Bag;
import org.apache.commons.collections4.bag.HashBag;

import java.util.Arrays;

/**
 * @author LiuYC
 * @version 1.0.0
 * @create 2020-12-27 22:31
 */
public class GuavaPackages {
    /**
     * 不可变集合
     */
    ImmutableList<String> list = ImmutableList.of("1", "3");
    ImmutableMap<Integer, String> map = ImmutableMap.of(1, "1", 3, "3");

    /**
     * 多值map
     */
    public static void main(String[] args) {
        System.out.println("多值map==============================");
        ArrayListMultimap<String, String> phoneMap = ArrayListMultimap.create();
        phoneMap.put("liuyuchao", "15143038938");
        phoneMap.put("liuyuchao", "16643553537");
        System.out.println(phoneMap.get("liuyuchao"));

        /**
         * table表的使用
         */
        System.out.println("table表的使用===========================");
        HashBasedTable<Object, Object, Object> graph = HashBasedTable.create();
        graph.put(31.12, 121.48, "人民广场");
        Object o = graph.get(31.12, 121.48);
        System.out.println(o);


        /**
         * bag的使用统计功能
         */
        Bag box = new HashBag(Arrays.asList("red", "blue", "black", "blue"));
        box.add("blue", 3);
        System.out.println("bag的使用统计功能================================");
        System.out.println(box.size());
        box.getCount("blue");


    }


}